<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-28 18:02:01
 * @LastEditTime: 2019-08-28 18:29:59
 * @LastEditors: Please set LastEditors
 -->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link href="style/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="style/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="style/lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
    <link href="style/css/style3.css" rel="stylesheet" type="text/css" />
    <script language="javascript"  src="modpub/js/check.js"> </script>
    {literal}
        <script type="text/javascript">
            function check(f){
                if(Trim(f.product_title.value)==""){
                    alert("产品名称不能为空！");
                    f.pname.value = '';
                    return false;
                }
                return true;
            }
        </script>
    {/literal}
    {literal}
        <style type="text/css">
            .input-text, .scinput_s{
                width: 300px;
            }
            .ra1{
    position: relative;
    width: 70px;
    margin-right: 20px;
    border: 1px solid #eee;
    border-radius: 5px;
    height: 30px;
    line-height: 30px;
    float: left;
}
.ra1 label{
    height: 30px;
    text-align: center;
    line-height: 30px;
    margin: 0 auto;
    width: 90%;
    left: 6px;
    background: none;
}
.ra1 input{
    float: left;
    position: absolute;
    height: 30px;
    line-height: 30px;
}
.formListSD {
    color: #414658;
}

.formContentSD {
    padding: 0;
    padding-top: 10px;
    position: relative;
}

.formTextSD {
    margin-right: 8px;
    width: 11%!important;
}

.formInputSD input,
.formInputSD select {
    width: 287px;
}

.formInputSD input[type='number'] {
    padding-left: 10px;
    margin-bottom: 10px;
}

.formInputSD select,
.formInputSD select {
    padding-left: 8px;
    margin-bottom: 10px;
}
.inputC:checked +label::before{
    top: 8px;
}
form[name=form1] input{
        margin: 0px;
    }
     .form-label{
        padding-right: 10px;
        margin-top: 3px;
    }
    .inputC+label{
        width: 50px;
        border: none;
    }
    .inputC:checked +label::before{
        display: inline-block;
    }
    .form-horizontal .formControls {
    padding-right: 10px;
}
    #masks {
        width: 100%;
        height: 100vh;
        position: absolute;
        z-index: 10002;
        background-color: #FFF;
        justify-content: center;
        align-items: center;
        display: flex;
    }

    #masks img {
        width: 50px;
    }
        </style>
    {/literal}
    <title>修改产品</title>
</head>
<body style="overflow-y:hidden;">
<div id="masks">
    <img src="images/icon1/loads.gif">
</div>
<div class="breadcrumb" style="margin-top: 0;"><i class="Hui-iconfont">&#xe616;</i> 产品管理 <span class="c-gray en">&gt;</span><a href="index.php?module=product" style="text-decoration:none;" onmouseover="this.style.color='#333'">产品列表管理</a><span class="c-gray en">&gt;</span>查看产品 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="#" onclick="location.href='index.php?module=product';" title="关闭"><i class="Hui-iconfont">&#xe6a6;</i></a></div>
<div class="pd-20" id="page">
    <form name="form1" action="index.php?module=product&action=modify" enctype="multipart/form-data" method="post">
        <input type="hidden" name="id" value='{$id}'/>
        <input type="hidden" name="uploadImg" value='{$uploadImg}'/>
        <input type="hidden" name="attribute" class="attribute" id="attribute" value='{$attribute1}'/>
        <input type="hidden" name="attribute_key" class="attribute_key" id="attribute_key" value='{$attribute_key2}'/>
        <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>产品标题：</label>
            <div class="formControls col-4" style="width: 16.8%;">
                <input type="text" class="input-text" value="{$product_title}" placeholder="" id="product_titleId" name="product_title" disabled>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-2"><span class="c-red"></span>副标题：</label>
            <div class="formControls" style="display: inline-block;">
                <input type="text" class="input-text" value="{$subtitle}" placeholder="" id="subtitleId" name="subtitle" disabled>
            </div>
            <text style="line-height:30px;">*简洁表达产品，用来显示在首页产品，避免截取时不能表达是什么产品。</text>
        </div>

        <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>产品类别：</label>
            <div class="formControls col-2"> <!-- <span class="select-box"> -->
                <select name="product_class" class="select" id="product_classId" disabled>
                    {$ctypes}
                </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-2"><span class="c-red"></span>产品品牌：</label>
            <div class="formControls col-2"><!--  <span class="select-box"> -->
                <select name="brand_class" class="select" id="brand_classId" disabled>
                    <!-- <option selected="selected" value="0">请选择品牌</option> -->
                        {$r02}
                </select>
                <!-- </span> -->
            </div>
        </div>
                <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>产品主图：</label>
            <div class="formControls col-xs-8 col-sm-10" style="width: 20%;">
                <input type="hidden" id="picurl" value="{$uploadImg}{$imgurl}" class="td-input" name="image"/>
                <input type="hidden" name="img_oldpic" value="{$imgurl}" >
                <img id="thumb_url" src='{$uploadImg}{$imgurl}' style="height:50px;width:50px">
                <!-- <span class="btn btn-success " id="image"  type="button" disabled>选择图片</span> -->
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-2">产品展示图：</label>
            <div class="formControls col-10">
                <div class="uploader-thum-container">
                    <!-- <input name="imgurls[]" id="imgurls"  multiple='multiple' type="file" style="width:210px;" accept="upload_image/x-png,image/gif,image/jpeg" / disabled> -->
                    {if $imgurls != ''}
                        {foreach from=$imgurls item=item name=f1}
                            <img class="pimg" src="{$uploadImg}{$item->product_url}" style="width: 50px;height: 50px;">
                        {/foreach}
                    {/if}
                    <!-- 注:最多五张,一定为.jpg格式 -->
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-2"><span class="c-red">*</span>重量：</label>
            <div class="formControls col-4" style="width: 26.8%;">
                <input type="text" class="input-text" value="{$weight}" placeholder="" id="weightId" name="weight" disabled>
            </div>
            <text style="line-height:30px;">克</text>
        </div>
        <div class="formDivSD">
            <div class="formContentSD">
                {literal}
                    <!-- 有规格 -->
                    <div >
                        <div class="arrt_bgcolor arrt_fiv" style="margin-right: 60px;">
                            <div v-if="attr_group_list && attr_group_list.length>0">
                                <table class="attr-table attr_table">
                                    <thead>
                                        <tr>
                                            <th v-for="(attr_group,i) in attr_group_list" v-if="attr_group.attr_list && attr_group.attr_list.length>0">
                                                {{attr_group.attr_group_name}}
                                            </th>
                                            <th>成本价</th>
                                            <th>原价</th>
                                            <th>售价</th>
                                            <th>库存</th>
                                            <th>单位</th>
                                            <th>上传图片</th>
                                        </tr>
                                    </thead>

                                    <tr v-for="(item,index) in checked_attr_list" class="arrt_tr">
                                        <input type="hidden"  v-bind:name="'attr['+index+'][cid]'" :value="item.cid">
                                        <td v-for="(attr,attr_index) in item.attr_list">
                                            <input type="hidden"  v-bind:name="'attr['+index+'][attr_list]['+attr_index+'][attr_id]'" v-bind:value="attr.attr_id">

                                            <input type="hidden" v-bind:name="'attr['+index+'][attr_list]['+attr_index+'][attr_name]'" v-bind:value="attr.attr_name">

                                            <input type="hidden" v-bind:name="'attr['+index+'][attr_list]['+attr_index+'][attr_group_name]'" v-bind:value="attr.attr_group_name">
                                            <span>{{attr.attr_name}}</span>
                                        </td>
                                        <td>
                                            <input class="form-control form-control-sm" type="number" onkeypress="return noNumbers(event)" min="0"  step="0.01"  v-bind:name="'attr['+index+'][costprice]'" :value="item.costprice" disabled>
                                        </td>
                                        <td>
                                            <input class="form-control form-control-sm" type="number" onkeypress="return noNumbers(event)" min="0"  step="0.01"  v-bind:name="'attr['+index+'][yprice]'" :value="item.yprice" disabled >
                                        </td>
                                        <td>
                                            <input class="form-control form-control-sm" type="number" onkeypress="return noNumbers(event)" min="0"  step="0.01"  v-bind:name="'attr['+index+'][price]'" :value="item.price" disabled>
                                        </td>
                                        <td>
                                            <input class="form-control form-control-sm" oninput="value=value.replace(/[^\d]/g,'')" v-bind:name="'attr['+index+'][num]'"  step="1" :value="item.num" disabled >
                                        </td>
                                        <td>
                                            <input class="unit" v-bind:name="'attr['+index+'][unit]'" :value="item.unit" style="border: 0px;background-color: transparent;" readOnly="readOnly" disabled>
                                        </td>

                                        <td>
                                            <div  class="upload-group form_group form_flex">
                                                <!-- 不存在 -->
                                                <div class="form_attr_img ">
                                                    <input type="hidden" :id="'picurl2'+index" v-bind:name="'attr['+index+'][img]'" datatype="*" nullmsg="请选择图片"/>
                                                        <img src="images/icon1/add_g_t.png" :id="'pic2'+index" class="upload-preview-img form_att select-file" @click="handleImageClick(item,index)" onclick="setTimeoutClick() ">
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                {/literal}
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>显示类型：</label>
            <div class="formControls col-xs-8 col-sm-8 skin-minimal">
                <div class="ra1">
                    <input name="s_type[]" type="checkbox" class="inputC" id="sex-1" value="1" {if in_array(1,$s_type)}checked="checked"{/if} disabled>
                    <label for="sex-1">新品</label>
                </div>
                <div class="ra1">
                    <input type="checkbox" id="sex-2" class="inputC" name="s_type[]" value="2" {if in_array(2,$s_type)}checked="checked"{/if} disabled>
                    <label for="sex-2">热销</label>
                </div>
                <div class="ra1">
                    <input type="checkbox" id="sex-3" class="inputC" name="s_type[]" value="3" {if in_array(3,$s_type)}checked="checked"{/if} disabled>
                    <label for="sex-3">推荐</label>
                </div>
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-2">拟定销量：</label>
            <div class="formControls col-2">
                <input type="number" class="input-text" value="{$volume}" name="volume" id="volumeId" disabled>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-2"><span class="c-red"></span>运费设置：</label>
            <div class="formControls col-2"> <!-- <span class="select-box"> -->
                <select name="freight" class="select" id="freightId" disabled>
                    {$freight_list}
                </select>
                <!-- </span> -->
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">详细内容：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <script id="editor" type="text/plain" name="content" style="width:100%;height:400px;" disabled>{$content}</script>
            </div>
        </div>
		<div style="height: 70px;"></div>
        <div class="row cl page_bort_bottom">
            <div class="col-8 col-offset-4">
                <input type="button" name="reset" value="返回"  class="btn btn-primary radius btn-right" id="resetId" onclick="javascript :history.back(-1);" style="background: transparent!important;">
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="style/js/jquery.js"></script>
<script type="text/javascript" src="style/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="style/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="style/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<!-- 新增编辑器引入文件 -->
<link rel="stylesheet" href="style/kindeditor/themes/default/default.css" />
<script src="style/kindeditor/kindeditor-min.js"></script>
<script src="style/kindeditor/lang/zh_CN.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
{literal}
<script>

$(function(){
    var ue = UE.getEditor('editor');
    ue.ready(function() {
//不可编辑
    ue.setDisabled();
    }); 
});


$(document).ready(function(){
    var imgList = getTheImgList();
    if(imgList){
        for(var i=0; i<imgList.length; i++){
            $('#pic2'+i).attr("src", imgList[i].img);
            $('#picurl2'+i).val(imgList[i].img);
        }
    }
});
// 获取属性值上传图片
function getTheImgList(){
    var imgList = JSON.parse('{/literal}{$checked_attr_list}{literal}', true)
    return imgList
}
$(document).ready(function(){
    //将数字字符串转为带两位小数的数字
    page.cbj = getFloatStr(page.cbj)
    page.yj = getFloatStr(page.yj)
    page.sj = getFloatStr(page.sj)
});
//将数字字符串转为带两位小数的数字
function getFloatStr(num){  
    num += '';  
    num = num.replace(/[^0-9|\.]/g, ''); //清除字符串中的非数字非.字符  
    
    if(/^0+/) //清除字符串开头的0  
        num = num.replace(/^0+/, '');  
    if(!/\./.test(num)) //为整数字符串在末尾添加.00  
        num += '.00';  
    if(/^\./.test(num)) //字符以.开头时,在开头添加0  
        num = '0' + num;  
    num += '00';        //在字符串末尾补零  
    num = num.match(/\d+\.\d{2}/)[0];  
    return num;
}
//控制价格显示小数点2位
    function noNumbers(e){
        console.log('onkeypress')
        console.log(e)
        var keynum
        var keychar
        var numcheck
        if(window.event) // IE
        {
            keynum = e.keyCode
        }
        else if(e.which) // Netscape/Firefox/Opera
        {
            keynum = e.which
        }
        keychar = String.fromCharCode(keynum);
        //判断是数字,且小数点后面只保留两位小数
        if(!isNaN(keychar)){
            var index=e.currentTarget.value.indexOf(".");
            if(index >= 0 && e.currentTarget.value.length-index >2){
                return false;
            }
            return true;
        }
        //如果是小数点 但不能出现多个 且第一位不能是小数点
        if("."== keychar ){
            if(e.currentTarget.value==""){
                return false;
            }
            if(e.currentTarget.value.indexOf(".") >= 0){
                return false;
            }
            return true;
        }
        return false;
    }

  // $('#unit').live('click', function() {
  //       var unit = $("#unit").val();
  //       page.unit = $("#unit").val();
  //       $(".unit").val(unit);
  //   });
  //   //设置成本价等
  //   function set_cbj(obj) {
  //       page.cbj = $(obj).val();
  //       if(page.checked_attr_list.length > 0){
  //           for (k in page.checked_attr_list){
  //               page.checked_attr_list[k].costprice = $(obj).val();
  //           }
  //       }

  //   }
  //   function set_yj(obj) {
  //       page.yj = $(obj).val();
  //       if(page.checked_attr_list.length > 0){
  //           for (k in page.checked_attr_list){
  //               page.checked_attr_list[k].yprice = $(obj).val();
  //           }
  //       }
  //   }
  //   function set_sj(obj) {
  //       page.sj = $(obj).val();
  //       if(page.checked_attr_list.length > 0){
  //           for (k in page.checked_attr_list){
  //               page.checked_attr_list[k].price = $(obj).val();
  //           }
  //       }
  //   }
  //   function set_kucun(obj) {
  //       page.kucun = $(obj).val();
  //       if(page.checked_attr_list.length > 0){
  //           for (k in page.checked_attr_list){
  //               page.checked_attr_list[k].num = $(obj).val();
  //           }
  //       }
  //   }


  //   var Map = function() {
  //       this._data = [];
  //       this.set = function(key, val) {
  //           for(var i in this._data) {
  //               if(this._data[i].key == key) {
  //                   this._data[i].val = val;
  //                   return true;
  //               }
  //           }
  //           this._data.push({
  //               key: key,
  //               val: val,
  //           });
  //           return true;
  //       };
  //       this.get = function(key) {
  //           for(var i in this._data) {
  //               if(this._data[i].key == key)
  //                   return this._data[i].val;
  //           }
  //           return null;
  //       };
  //       this.delete = function(key) {
  //           for(var i in this._data) {
  //               if(this._data[i].key == key) {
  //                   this._data.splice(i, 1);
  //               }
  //           }
  //           return true;
  //       };
  //   };
    var map = new Map();
var page = new Vue({
        el: "#page",
        data: {
            sub_cat_list: [],
            attr_group_list: JSON.parse('{/literal}{$attr_group_list}{literal}', true), //可选规格数据
            attr_group_count: JSON.parse('{/literal}{$attr_group_list}{literal}', true).length,
            checked_attr_list: JSON.parse('{/literal}{$checked_attr_list}{literal}', true), //已选规格数据
            old_checked_attr_list: [],
            goods_card_list: [],
            card_list: [],
            goods_cat_list: [{
                "cat_id": null,
                "cat_name": null
            }],
            select_i: '',
            cbj:'{/literal}{$initial->cbj}{literal}',
            yj:'{/literal}{$initial->yj}{literal}',
            sj:'{/literal}{$initial->sj}{literal}',
            kucun:'{/literal}{$initial->kucun}{literal}',
            unit:'{/literal}{$initial->unit}{literal}',
            imageClickInfo:'',
            imageClickInfoIndex:0
        },
        created:function(){
            this.$nextTick(function () {
                $('#masks').hide()
                $(document.body).css({
                    "overflow-y": "auto"
                })
            })
        },
        methods: {
            change: function(item, index) {
                this.checked_attr_list[index] = item;
            },
            handleImageClick(data,index){
                this.imageClickInfo = data;
                this.imageClickInfoIndex = index
            }
        }
    });
    // console.log('checked_attr_list 全局')
    // console.log(page.checked_attr_list)
    // console.log(page)
//     // 点击属性框，显示添加属性按钮
//     $(".add-attr-group-input").live("click", function(){
//         $(".add-attr-group-btn").css("display", "");
//     });
//     // 属性框离开事件，延迟500毫秒隐藏隐藏添加属性按钮
//     $(".add-attr-group-input").blur(function(){
//         setTimeout('$(".add-attr-group-btn").css("display", "none")', 500);
//     });
//     // 添加属性
//     $( ".add-attr-group-btn").live("click", function() {
//         var name = $(".add-attr-group-input").val();
//         name = $.trim(name);
//         if(name == ""){
//             alert("属性名不能为空！");
//             return;
//         }

//         for(var i in page.attr_group_list) {
//             if(page.attr_group_list[i].attr_group_name == name){
//                 alert("属性名称重复！");
//                 return;
//             }
//         }
//         page.attr_group_list.push({
//             attr_group_name: name,
//             attr_list: [],
//         });
//         $(".add-attr-group-input").val("");
//         page.checked_attr_list = getAttrList();
//         //获取属性值上传图片
//         getTheImgList()
//         console.log('checked_attr_list')
//         console.log(page.checked_attr_list)
//     });
//     // 添加属性值
//     $( ".add-attr-btn").live("click", function() {
//         var name = $(this).parents(".attr-input-group").find(".add-attr-input").val();
//         var index = $(this).attr("index");
//         name = $.trim(name);
//         if(name == ""){
//             alert("属性值不能为空！");
//             return;
//         }

//         /**筛选重复*/
//         var ck_list = page.checked_attr_list;
//         if(ck_list.length > 0){
//             for(var pi in ck_list) {
//                 if(ck_list[pi].attr_list[index]){
//                     if(name == ck_list[pi].attr_list[index].attr_name){
//                         alert("属性值重复！");
//                         return;
//                     }
//                 }
//             }
//         }
//         /**筛选重复*/

//         page.attr_group_list[index].attr_list.push({
//             attr_name: name,
//             status:true
//         });
//         // 如果是单规格的，添加新规格时不清空原先的数据
//         page.old_checked_attr_list = page.checked_attr_list;
//         var attrList = getAttrList();
//         if(page.attr_group_list.length === 1) {
//             for(var i in attrList) {
//                 if(i > page.old_checked_attr_list.length - 1) {
//                     page.old_checked_attr_list.push(attrList[i])
//                 }
//             }
//             var newCheckedAttrList = page.old_checked_attr_list;
//         } else if(page.attr_group_list.length === page.attr_group_count) {
//             for(var pi in attrList) {
//                 var pAttrName = '';
//                 for(var pj in attrList[pi].attr_list) {
//                     pAttrName += attrList[pi].attr_list[pj].attr_name
//                 }
//                 for(var ci in page.old_checked_attr_list) {
//                     var cAttrName = '';
//                     for(var cj in page.old_checked_attr_list[ci].attr_list) {
//                         cAttrName += page.old_checked_attr_list[ci].attr_list[cj].attr_name;
//                     }
//                     if(pAttrName === cAttrName) {
//                         attrList[pi] = page.old_checked_attr_list[ci];
//                     }
//                 }
//             }
//             var newCheckedAttrList = attrList;
//         } else {
//             var newCheckedAttrList = attrList;
//         }
//         $(this).parents(".attr-input-group").find(".add-attr-input").val("");
//         page.checked_attr_list = newCheckedAttrList;
//     });
//     // 删除属性
//     $( ".attr-group-delete").live("click",function() {
//         var index = $(this).attr("index");
//         page.attr_group_list.splice(index, 1);
//         page.checked_attr_list = getAttrList();
//     });
//     // 删除属性值
//     $(".attr-delete").live("click", function() {
//         var index = $(this).attr("index");
//         var group_index = $(this).attr("group-index");
//         console.log(page.attr_group_list[group_index]);
//         page.attr_group_list[group_index].attr_list.splice(index, 1);
//         // 如果是单规格的，删除规格时不清空原先的数据
//         page.old_checked_attr_list = page.checked_attr_list;
//         var attrList = getAttrList();
//         if(page.attr_group_list.length === 1) {
//             var newCheckedAttrList = [];
//             for(var i in page.attr_group_list[0].attr_list) {
//                 var attrName = page.attr_group_list[0].attr_list[i].attr_name;
//                 for(j in page.old_checked_attr_list) {
//                     var oldAttrName = page.old_checked_attr_list[j].attr_list[0].attr_name;
//                     if(attrName === oldAttrName) {
//                         newCheckedAttrList.push(page.old_checked_attr_list[j]);
//                         break;
//                     }
//                 }
//             }
//         } else if(page.attr_group_list.length === page.attr_group_count) {
//             for(var pi in attrList) {
//                 var pAttrName = '';
//                 for(var pj in attrList[pi].attr_list) {
//                     pAttrName += attrList[pi].attr_list[pj].attr_name
//                 }
//                 for(var ci in page.old_checked_attr_list) {
//                     var cAttrName = '';
//                     for(var cj in page.old_checked_attr_list[ci].attr_list) {
//                         cAttrName += page.old_checked_attr_list[ci].attr_list[cj].attr_name;
//                     }
//                     if(pAttrName === cAttrName) {
//                         attrList[pi] = page.old_checked_attr_list[ci];
//                     }
//                 }
//             }
//             var newCheckedAttrList = attrList;
//         } else {
//             var newCheckedAttrList = attrList;
//         }

//         page.checked_attr_list = newCheckedAttrList;
//     });

//     function getAttrList() {
//         var array = [];
//         for(var i in page.attr_group_list) {
//             for(var j in page.attr_group_list[i].attr_list) {
//                 var object = {
//                     attr_group_name: page.attr_group_list[i].attr_group_name,
//                     attr_id: null,
//                     attr_name: page.attr_group_list[i].attr_list[j].attr_name,
//                 };
//                 if(!array[i])
//                     array[i] = [];
//                 array[i].push(object);
//             }
//         }

//         var len = array.length;
//         var results = [];
//         var indexs = {};
//         function specialSort(start) {
//             start++;
//             if(start > len - 1) {
//                 return;
//             }
//             if(!indexs[start]) {
//                 indexs[start] = 0;
//             }
//             if(!(array[start] instanceof Array)) {
//                 array[start] = [array[start]];
//             }

//             for(indexs[start] = 0; indexs[start] < array[start].length; indexs[start]++) {
//                 specialSort(start);
//                 if(start == len - 1) {
//                     var temp = [];
//                     for(var i = len - 1; i >= 0; i--) {
//                         if(!(array[start - i] instanceof Array)) {
//                             array[start - i] = [array[start - i]];
//                         }
//                         if(array[start - i][indexs[start - i]]) {
//                             temp.push(array[start - i][indexs[start - i]]);
//                         }
//                     }

//                     var key = [];
//                     for(var i in temp) {
//                         key.push(temp[i].attr_id);
//                     }
//                     var oldVal = map.get(key.sort().toString());
//                     console.log('getAttrList key')
//                     console.log(key)
//                     var unit = $("#unit").val();
//                     if(oldVal) {
//                         console.log('getAttrList 有oldVal')
//                         results.push({
//                             attr_list: temp,
//                             costprice: oldVal.no,
//                             yprice: oldVal.pic,
//                             price: oldVal.price,
//                             num: oldVal.num,
//                             unit: unit,
//                             img: '',
//                         });
//                     } else {
//                         console.log('getAttrList 无oldVal')
//                         console.log(page)
//                         var img = $(".upload-preview-list").children(":first").children('.upload-preview-img').attr('src');
//                         results.push({
//                             attr_list: temp,
//                             costprice: page.cbj,
//                             yprice: page.yj,
//                             price: page.sj,
//                             num: page.kucun,
//                             unit: unit,
//                             img: img
//                         });
//                     }
//                 }
//             }
//         }
//         specialSort(-1);
//         return results;
//     }
           
//     document.onkeydown = function(e) {
//         if(!e) e = window.event;
//         if((e.keyCode || e.which) == 13) {
//             $("[name=Submit]").click();
//         }
//     }

//     var t_check = true;
            
//     var GetLength = function (str) {
//         ///<summary>获得字符串实际长度，中文2，英文1</summary>
//         ///<param name="str">要获得长度的字符串</param>
//         var realLength = 0, len = str.length, charCode = -1;
//         for (var i = 0; i < len; i++) {
//             charCode = str.charCodeAt(i);
//             if (charCode >= 0 && charCode <= 128) realLength += 1;
//             else realLength += 2;
//         }
//           return realLength;
//     };

//     function check() {
//         var url = 'index.php?module=product&action=modify';
//         if(!t_check){
//             alert('请勿重复提交！', {
//                 time: 2000
//             });
//             return false;
//         }

//         t_check = false;
//         $.ajax({
//             cache: true,
//             type: "POST",
//             dataType: "json",
//             url: url,
//             data: $('#form1').serialize(), // 你的formid
//             async: true,
//             success: function(data) {
//                 t_check = true;
//                 layer.msg(data.status, {
//                     time: 2000
//                 });
//                 if(data.suc) {
//                     location.href ='index.php?module=product&action=Index&cid='+del_str.cid+'&brand_id='+del_str.brand_id+'&status='+status+'&s_type='+'&product_title='+del_str.product_title+'&show_adr='+del_str.show_adr+'&page='+del_str.page+'&pagesize='+del_str.pagesize;
//                 }
//             }
//         });
//     }


// function setTimeoutClick(){
//     console.log('timeout')
//     setTimeout(image_click, 100);
// }

// // 属性值上传商品图片
// function image_click() {
//     console.log('image click')
//     var id = page.imageClickInfoIndex
//     console.log(page.imageClickInfoIndex)

//     KindEditor.ready(function (K) {
//         var editor = K.editor({
//             allowFileManager: true,
//             uploadJson: "index.php?module=system&action=uploadImg", //上传功能
//             fileManagerJson: 'kindeditor/php/file_manager_json.php', //网络空间
//         });
//         editor.loadPlugin('image', function () {
//             editor.plugin.imageDialog({
//                 showRemote: false, //网络图片不开启
//                 //showLocal : false, //不开启本地图片上传
//                 imageUrl: K("#picurl2"+id).val(),
//                 clickFn: function (url, title, width, height, border, align) {
//                     K('#picurl2'+id).val(url);
//                     $('#picurl2'+id).val(url)
//                     $('#pic2'+id).attr("src", url);
//                     editor.hideDialog();
//                     console.log(url)
//                     console.log($('#picurl2'+id).val())
//                 }
//             });
//         });
//     });

// }


// function resetButton(){
//     $('#product_numberId').val("");
//     $('#product_titleId').val("");
//     $('#subtitleId').val("");
//     $("#product_classId option[value='0']").attr("selected", "selected");
//     $("#brand_classId option[value='0']").attr("selected", "selected");
//     $('#weightId').val("");
//     $('#sex-1').attr("checked","");
//     $('#sex-2').attr("checked","");
//     $('#sex-3').attr("checked","");
//     $('#volumeId').val("");
//     $("#freightId option[value='0']").attr("selected", "selected");
//     $('#ueditor_0').contents().find('p').html("");
// }
</script>
{/literal}
</body>
</html>